import { defineConfig, globalIgnores } from 'eslint/config'
import globals from 'globals'
import js from '@eslint/js'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import parser from 'vue-eslint-parser'

export default defineConfig([
  {
    name: 'app/files-to-lint',
    files: ['**/*.{js,mjs,jsx}'],
    rules: {
      'no-undef': 'error' // 禁止未声明的变量
    }
  },

  {
    files: ['**/*.vue'],
    languageOptions: {
      parser
    },
    rules: {
      'vue/multi-word-component-names': ['warn', { ignores: ['index'] }], // 关闭多单词组件名限制
      'vue/no-setup-props-destructure': 'off', // 允许解构 props
    }
  },

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ElMessage: "readonly",
        ElMessageBox: "readonly",
        ElLoading: "readonly"
      }
    }
  },

  js.configs.recommended,
  ...pluginVue.configs['flat/essential'],
  skipFormatting
])
